import java.util.Scanner;

public class GuessNumber {
    public static void main(String[] args) {
        int a=(int)(Math.random()*100+1);
        int b;
        int c=7;
        Scanner sc=new Scanner(System.in);
        do {
            System.out.println("请输入1-100的数字");
            b=sc.nextInt();
            if (b<1||b>100){
                System.out.println("请输入大于等于1或小于等于100的数");
            }else if(b>=1&&b<=100){
                if (b>a){
                    c--;
                    System.out.println("大了,你还有"+c+"次机会");
                }else if(b<a){
                    c--;
                    System.out.println("小了,你还有"+c+"次机会");
                }
            }else if (b==a){
                System.out.println("对了");
                break;
            }
            if (c==0){
                System.out.println("是否再玩一局?是:1,否:2");
                String d=sc.next();
                if (d.equals("1")){
                    a=(int)(Math.random()*100+1);
                    c=7;
                }else if (d.equals("2")){
                    break;
                }
            }
        }while(b!=a);

    }
}
